import pyecharts.options as opts
from pyecharts.charts import WordCloud
import pandas as pd


duringTimes = pd.read_csv('data/四川各地上班时长统计.csv',encoding='utf-8')
print(duringTimes)
city_groupby = duringTimes['平均上班时长'].groupby(duringTimes['城市']).count() #按学历分组 count统计re人数
print(type(city_groupby))
valuelist = list(city_groupby)
namelist = list(city_groupby.keys())
data = list(zip(namelist,valuelist))
print(data)


(
    WordCloud()
    .add(series_name="热点分析", data_pair=data, word_size_range=[6, 66])
    .set_global_opts(
        title_opts=opts.TitleOpts(
            title="热点分析", title_textstyle_opts=opts.TextStyleOpts(font_size=23)
        ),
        tooltip_opts=opts.TooltipOpts(is_show=True),
    )
    .render("basic_wordcloud.html")
)